/**
 * 
 */
package fr.utbm.gi.vi51.slizers.framework.learning;

import java.io.Serializable;
import java.util.Comparator;

/**
 * Implementation of a comparator for a Q-Learning store.
 * 
 * @author Tarik Belabbas
 * 
 */
public class QComparator implements Comparator< QComparable >, Serializable
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 7385686591110292592L;

	/**
	 * Default constructor.
	 */
	public QComparator()
	{
		
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
	 */
	@Override
	public int compare( QComparable _comparable1, QComparable _comparable2 )
	{
		if ( _comparable1 == _comparable2 )
		{
			return 0;
		}
		
		if ( _comparable1 == null )
		{
			return Integer.MIN_VALUE;
		}
		
		if ( _comparable2 == null )
		{
			return Integer.MAX_VALUE;
		}
		
		return _comparable1.toInt() - _comparable2.toInt();
	}
}
